package luogu.bfs;
//P1443 马的遍历

import java.util.*;

/**
 * @author :chenjie
 * @date :Created 2022/12/23 23:05
 */
public class TheTraversalOFTheHorse {
    static class Pall{
        int x;
        int y;
        int l;

        public Pall(int x, int y, int l) {
            this.x = x;
            this.y = y;
            this.l = l;
        }
    }
    static int[][]st=new int[410][410];
    static int n,m;
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        n=sc.nextInt();
        m=sc.nextInt();
        int x=sc.nextInt();
        int y=sc.nextInt();
        bfs(x,y);
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                System.out.print(st[i][j]+"    ");
            }
            System.out.println();
        }

    }
    public static void bfs(int x,int y){
        int[]dx={-1,-2,-2,-1,1,2,2,1};
        int[]dy={2,1,-1,-2,2,1,-1,-2};
        Queue<Pall> queue=new ArrayDeque<>();
        queue.add(new Pall(x,y,0));
        for (int i = 1; i <= n; i++) {
            Arrays.fill(st[i],-1);
        }
        st[x][y]=0;
        while (!queue.isEmpty()){
            Pall axis = queue.remove();

            for (int i = 0; i < 8; i++) {
                int a=axis.x+dx[i],b=axis.y+dy[i];
                if(a>=1&&a<=n&&b>=1&&b<=m&&st[a][b]==-1){
                    queue.add(new Pall(a,b,axis.l+1));
                    st[a][b]=axis.l+1;
                }
            }
        }

    }
}
